<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table,td{
            border: 2px solid #ddd;
            border-collapse: collapse;
        }
        td{padding: 10px;}
    </style>
</head>
<body>
    <div id="box"></div>
    <!-- <table><tr><td></td><td></td></tr></table> -->
    <script>
        var data=[{
            StudentNumber:1,
            Chinese:105,
            Math:62,
            English:118,
            TotalScore:"285",
            Comment:"优秀"
        },
        {
            StudentNumber:2,
            Chinese:89,
            Math:78,
            English:120,
            TotalScore:"234",
            Comment:"优秀"
        },
        {
            StudentNumber:3,
            Chinese:86,
            Math:64,
            English:80,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:4,
            Chinese:78,
            Math:99,
            English:91,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:5,
            Chinese:107.5,
            Math:97,
            English:70,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:6,
            Chinese:112,
            Math:61,
            English:92,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:7,
            Chinese:101,
            Math:79,
            English:104,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:8,
            Chinese:71,
            Math:72,
            English:105,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:9,
            Chinese:56,
            Math:68,
            English:61,
            TotalScore:"",
            Comment:"优秀"
        },
        {
            StudentNumber:10,
            Chinese:98,
            Math:83,
            English:77,
            TotalScore:"",
            Comment:"优秀"
        }
    ]
    data.forEach(function (item,index,array) {
        item.TotalScore=item.Chinese+item.Math+item.English;
        if(item.TotalScore>250){
            item.Comment="wasai!!!!!"
        }else{
            item.Comment="加油!!!!!"
        }
    })
    data.sort(function(a,b){
        return a.TotalScore-b.TotalScore
    })

    var str="<table>";
         data.forEach(function (item,index,array) {
        // console.log(item);
        str+="<tr>"//拼接tr
            for(var key in item){
                // console.log(item[key]);
                str+='<td>'+item[key]+'</td>'
            }
        str+="</tr>"
    })
    str+="</table>";
    box.innerHTML=str;
    </script>
</body>
</html>